package com.kxmall.web.controller.huishou;

import java.util.List;
import java.util.Arrays;

import cn.dev33.satoken.annotation.SaIgnore;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.kxmall.common.annotation.RepeatSubmit;
import com.kxmall.common.annotation.Log;
import com.kxmall.common.core.controller.BaseController;
import com.kxmall.common.core.domain.PageQuery;
import com.kxmall.common.core.domain.R;
import com.kxmall.common.core.validate.AddGroup;
import com.kxmall.common.core.validate.EditGroup;
import com.kxmall.common.enums.BusinessType;
import com.kxmall.common.utils.poi.ExcelUtil;
import com.kxmall.huishou.domain.vo.HsActivityJoinVo;
import com.kxmall.huishou.domain.bo.HsActivityJoinBo;
import com.kxmall.huishou.service.IHsActivityJoinService;
import com.kxmall.common.core.page.TableDataInfo;

/**
 * 活动报名记录
 *
 * @author kxmall
 * @date 2023-11-23
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/huishou/activityJoin")
public class HsActivityJoinController extends BaseController {

    private final IHsActivityJoinService iHsActivityJoinService;

    /**
     * 查询活动报名记录列表
     */
    @SaCheckPermission("huishou:activityJoin:list")
    @GetMapping("/list")
    public TableDataInfo<HsActivityJoinVo> list(HsActivityJoinBo bo, PageQuery pageQuery) {
        return iHsActivityJoinService.queryPageList(bo, pageQuery);
    }



    /**
     * 导出活动报名记录列表
     */
    @SaCheckPermission("huishou:activityJoin:export")
    @Log(title = "活动报名记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HsActivityJoinBo bo, HttpServletResponse response) {
        List<HsActivityJoinVo> list = iHsActivityJoinService.queryList(bo);
        ExcelUtil.exportExcel(list, "活动报名记录", HsActivityJoinVo.class, response);
    }

    /**
     * 获取活动报名记录详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("huishou:activityJoin:query")
    @GetMapping("/{id}")
    public R<HsActivityJoinVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(iHsActivityJoinService.queryById(id));
    }



    /**
     * 修改活动报名记录
     */
//    @SaCheckPermission("huishou:activityJoin:edit")
//    @Log(title = "活动报名记录", businessType = BusinessType.UPDATE)
//    @RepeatSubmit()
//    @PutMapping()
//    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HsActivityJoinBo bo) {
//        return toAjax(iHsActivityJoinService.updateByBo(bo));
//    }

    /**
     * 删除活动报名记录
     *
     * @param ids 主键串
     */
//    @SaCheckPermission("huishou:activityJoin:remove")
//    @Log(title = "活动报名记录", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{ids}")
//    public R<Void> remove(@NotEmpty(message = "主键不能为空")
//                          @PathVariable Long[] ids) {
//        return toAjax(iHsActivityJoinService.deleteWithValidByIds(Arrays.asList(ids), true));
//    }
}
